package com.rodvl.core;


import com.rodvl.common.web.TimerInterceptor;
import com.rodvl.core.support.ForeInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author lzb22
 */
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {

    private final ForeInterceptor foreInterceptor;

    public WebMvcConfig(ForeInterceptor foreInterceptor) {
        this.foreInterceptor = foreInterceptor;
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new TimerInterceptor());
        registry.addInterceptor(foreInterceptor).excludePathPatterns("/error/**");
        WebMvcConfigurer.super.addInterceptors(registry);
    }
}
